set maxvar 32767

* Obtain information about the districts of respondents
use "/Users/e_indresp.data"
merge 1:1  using "/Users/e_oslaua_protect.data"
renpfix e_
save "/Users/survey_2013"

use "/Users/f_indresp.data"
merge 1:1  using "/Users/g_oslaua_protect.data"
renpfix f_
save "/Users/survey_2014"

use "/Users/g_indresp.data"
merge 1:1  using "/Users/g_oslaua_protect.data"
renpfix g_
save "/Users/survey_2015"

use "/Users/h_indresp.data"
merge 1:1  using "/Users/h_oslaua_protect.data"
renpfix h_
save "/Users/survey_2016"

* Merge UKHLS waves
use "/Users/survey_2013"
append using "/Users/survey_2014"
append using "/Users/survey_2015"
append using "/Users/survey_2016"

** Harmonize variables
recode  sex (-9=.) (-1=.) (1=0) (2=1), gen (gender)
recode race (1=1) (-9=.) (2/97=0), gen(ethnicity)
recode jbnssec3 (-9 -8=.) , gen(job_3)

keep if (qfhigh > 0)
gen education=qfhigh
recode education 1/7=1 7/11=2 12/16=3 96=4
label define edu1 1 "Higher degree" 2 "High School or vocational" 3 "GCSE"4 "No qual"
lab val education edu1

recode vote3  (12=1) (1/11=0) (-8=.) (-7=.) (-2=.) (-1=0) (95=0) (96=0) (97=0) (13=0), gen (support)
recode vote3  (12=1) (1/11=0) (-8=.) (-7=.) (-2=.) (-1=0) (95=0) (96=0) (97=0) (13=0), gen (support1)
recode vote3  (1=1) (2/12=0) (-8=.) (-7=.) (-2=.) (-1=0) (95=0) (96=0) (97=0) (13=0), gen (support_Cons)
recode vote3  (2=1) (3/12=0) (-8=.) (-7=.) (-2=.) (-1=0) (95=0) (96=0) (97=0) (13=0) (1=0), gen (support_Labour) 

save as "/Users/survey.dta" 
